﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace MyMeetup.Controls
{
    public delegate void GroupSelectedEventHandler(object sender, GroupSelectedEventArgs e);

    public partial class GroupPicker : UserControl
    {
        public IEnumerable DataSource { get { return groupList.ItemsSource; } set { groupList.ItemsSource = value; } }

        public GroupPicker()
        {
            InitializeComponent();
        }

        public event GroupSelectedEventHandler GroupSelected;
        protected virtual void OnGroupSelected(GroupSelectedEventArgs e)
        {
            if (GroupSelected != null)
                GroupSelected(this, e);
        }

        protected void Group_Click(object sender, RoutedEventArgs e)
        {
            IGroup group = sender as IGroup;
            OnGroupSelected(new GroupSelectedEventArgs{GroupId = group.id.ToString()});
        }
    }

    public class GroupSelectedEventArgs :EventArgs
    {
        public string GroupId { get; set; }
    }
}
